package com.dg.core.controller;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.ModelAndView;

import com.dg.core.pojo.Page;
import com.dg.core.pojo.ParamsData;

public class BaseController{
	protected Logger logger = Logger.getLogger(this.getClass());
	
	protected ModelAndView mv = this.getModelAndView();
	
	protected ParamsData pd = new ParamsData();
	
	public ParamsData getParamsData(){
		return new ParamsData(this.getRequest());
	}
	
	/**
	 * 得到ModelAndView
	 */
	public ModelAndView getModelAndView(){
	  return new ModelAndView();
	}
	
	/**
	 * 得到request对象
	 */
	public HttpServletRequest getRequest(){
	  HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
	  return request;
	}
	
	/**
	 * 得到分页列表的信息 
	 */
	public Page getPage(){
	  return new Page();
	}
	
	public static void logBefore(Logger logger, String interfaceName){
	  logger.info("");
	  logger.info("start");
	  logger.info(interfaceName);
	}
	
	public static void logAfter(Logger logger){
	  logger.info("end");
	  logger.info("");
	}
}

